package comits.web.client.servlets.demo;

import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import comits.business.tiers.metiers.Boutique;
import comits.business.tiers.rp.tasks.ws.ControleurCalculPrevisions;
/*import comits.web.client.servlets.gestion.drp.ComITSBusinessTiers10SNAPSHOTCallbackHandler;
import comits.web.client.servlets.gestion.drp.ComITSBusinessTiers10SNAPSHOTStub;
import comits.web.client.servlets.gestion.drp.ComITSBusinessTiers10SNAPSHOTStub.CalculPrevision;
import comits.web.client.servlets.gestion.drp.ComITSBusinessTiers10SNAPSHOTStub.CalculPrevisionResponse;
import comits.web.client.servlets.gestion.drp.ComITSBusinessTiers10SNAPSHOTStub.LancerCalculDRP;
import comits.web.client.servlets.gestion.drp.ComITSBusinessTiers10SNAPSHOTStub.LancerCalculDRPResponse;
*/
public class PrevisionsServlet extends HttpServlet {
	
	private static final long serialVersionUID = 7526928611471348888L;
	

	public void init() throws ServletException {
	}

	
	protected void processRequest(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

	protected void doGet(HttpServletRequest request,
		HttpServletResponse response) throws ServletException, IOException {
		}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		
		HttpSession session = request.getSession();  
		
		int horizon =  Integer.parseInt(request.getParameter("horizon"));
		float alpha =  Float.parseFloat(request.getParameter("alpha"));
		float beta =  Float.parseFloat(request.getParameter("beta"));
		float gamma = Float.parseFloat(request.getParameter("gamma")); 
		
		
		// mettre ce qui est dans le main  de calculerPrevisions cest ce que douguy a dit
		
		ControleurCalculPrevisions ccp = new ControleurCalculPrevisions(alpha, beta, gamma, horizon);
		ccp.calculprev();
		//ComITSBusinessTiers10SNAPSHOTCallbackHandler cBHand = new ComITSBusinessTiers10SNAPSHOTCallbackHandler();
		
		/*
		 APPEL WS 
		  
		 ComITSBusinessTiers10SNAPSHOTStub stub = new ComITSBusinessTiers10SNAPSHOTStub();
		CalculPrevision calcPrev = new CalculPrevision();
		calcPrev.setAlpha(alpha);
		calcPrev.setBeta(beta);
		calcPrev.setGamma(gamma);
		calcPrev.setHorizon(horizon);
		CalculPrevisionResponse response1 = stub.calculPrevision(calcPrev);		
		boolean cPrev = response1.get_return();*/
		
		List<Boutique> listBtq = (List<Boutique>) session.getAttribute("listBtq");
			
		getServletContext().getRequestDispatcher("/PrevGraphServlet?btq=" + listBtq.get(0).getNumBtq()).forward(request, response);
		
	}

	public String getServletInfo() {
		return "Short description";
	}// </editor-fold>
}